#include "test_meta_system.h"
#include <sea_statemachine>

// -------------------------------------------------------------------------------------------------

using namespace sea;

class ActiveObject : public StateMachine
{
public:
    ActiveObject( ) : StateMachine( STATEMACHINE_NAME )
    { 
    }

    ACT( ActiveObject, do_init );
    ACT( ActiveObject, do_idle );
    ACT( ActiveObject, do_end );
    ACT( ActiveObject, do_something );

    EVENT_EXT( ActiveObject, event1 );
    EVENT_EXT( ActiveObject, event2 );
    EVENT_EXT( ActiveObject, event3 );

private:

    EVENT_INT( ActiveObject, event4 );
};

// -------------------------------------------------------------------------------------------------

#if defined( STATIC_META_DATA_ENABLED )

EVENT_IMPL( ActiveObject, event1 );
EVENT_IMPL( ActiveObject, event2 );
EVENT_IMPL( ActiveObject, event3 );
EVENT_INT_IMPL( ActiveObject, event4 );

#endif

// -------------------------------------------------------------------------------------------------

ACT_IMPL( ActiveObject, do_init )
{
    SEA_UNUSED_PARAM( );
    SEA_TRACE( "%x %s", event1( ), event1.name( ) );
}

// -------------------------------------------------------------------------------------------------

ACT_IMPL( ActiveObject, do_idle )
{
    SEA_UNUSED_PARAM( );
    SEA_TRACE( "%x %s", event2( ), event2.name( ) );
}

// -------------------------------------------------------------------------------------------------

ACT_IMPL( ActiveObject, do_something )
{
    SEA_UNUSED_PARAM( );
    SEA_TRACE( "%x %s", event4( ), event4.name( ) );
}

// -------------------------------------------------------------------------------------------------

ACT_IMPL( ActiveObject, do_end )
{
    SEA_UNUSED_PARAM( );
    SEA_TRACE( "%x %s", event3( ), event3.name( ) );
}

// -------------------------------------------------------------------------------------------------

void test_meta_system( )
{
    /*{
        ActiveObject machine;

        MetaSystemRegistryEntry* registry = machine.registry( );

        // Internal API, Invoke action function by index
        for( unsigned i = 0; i < registry->m_actions.size( ); i++ )
        {
            INVOKE_ACTION_BY_INDEX( machine, i, NULL );
        }

        // Internal API, invoke action function by name
        INVOKE_ACTION_BY_NAME( machine, do_init, NULL );
        INVOKE_ACTION_BY_NAME( machine, do_idle, NULL );
        INVOKE_ACTION_BY_NAME( machine, do_end, NULL );

        // Internal API, get event index by its name
        SEA_TRACE( "%d", EVENT_BY_NAME( machine, event1 ) );
        SEA_TRACE( "%d", EVENT_BY_NAME( machine, event2 ) );
        SEA_TRACE( "%d", EVENT_BY_NAME( machine, event3 ) );


        // Internal API, get event index 
        for( unsigned i = 0; i < registry->m_events.size( ); i++ )
        {
            SEA_TRACE( "%x", EVENT_BY_INDEX( machine, i ) );
        }

        // External API, get event index of the state machine
        SEA_TRACE( "%d", machine.event1( ) );
        SEA_TRACE( "%d", machine.event2( ) );
        SEA_TRACE( "%d", machine.event3( ) );


        // External API, get event name of the state machine
        SEA_TRACE( "%s", machine.event1.name( ) );
        SEA_TRACE( "%s", machine.event2.name( ) );
        SEA_TRACE( "%s", machine.event3.name( ) );

        MetaSystem::destroy( );
    }

    */
}

// -------------------------------------------------------------------------------------------------



